package br.edu.univas.jobmanager.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

import br.edu.univas.jobmanager.listener.ButtonListener;

public class PanelGravarLimparButtons extends JPanel {
	private static final long serialVersionUID = 8781900571961244965L;
	private JButton gravarButton;
	private JButton limparButton;
	
	private ButtonListener _listener;
	public PanelGravarLimparButtons() {
		initialize();
		
	}
	private void initialize() {
		add(getGravarButton());
		add(getLimparButton());
		
	}
	public void setListener(ButtonListener _listener){
		this._listener = _listener;
	}
	private JButton getGravarButton() {
		if(gravarButton == null){
			gravarButton = new JButton("Gravar");
			gravarButton.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					_listener.gravarAction();
				}
			});
		}
		return gravarButton;
	}
	private JButton getLimparButton() {
		if(limparButton == null){
			limparButton = new JButton("Limpar");
			limparButton.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					_listener.limparAction();
				}
			});
		}
		return limparButton;
	}	
}
